﻿namespace AgileZen.Models
{
    using System;
    using System.Runtime.Serialization;
    using System.ComponentModel.DataAnnotations;

    [DataContract(Name = "phase")]
    public class Phase : AgileZenModel
    {
        private int _id;
        private string _name;
        private string _description;
        private int? _index;

        [DataMember(Name = "id", Order = 1, EmitDefaultValue = false)]
        public int Id
        {
            get { return _id; }
            set { _id = value; NotifyPropertyChanged("Id"); }
        }

        public bool ShouldSerializeId()
        {
            return PropertiesChanged.Contains("Id");
        }


        [Required]
        [DataMember(Name = "name", Order = 4, EmitDefaultValue = false)]
        public string Name
        {
            get { return _name; }
            set { _name = value; NotifyPropertyChanged("Name"); }
        }

        public bool ShouldSerializeName()
        {
            return PropertiesChanged.Contains("Name");
        }

        [Required]
        [DataMember(Name = "description", Order = 0, EmitDefaultValue = false)]
        public string Description
        {
            get { return _description; }
            set { _description = value; NotifyPropertyChanged("Description"); }
        }

        public bool ShouldSerializeDescription()
        {
            return PropertiesChanged.Contains("Description");
        }

        [DataMember(Name = "index", Order = 2, EmitDefaultValue = false)]
        public int? Index
        {
            get { return _index; }
            set { _index = value; NotifyPropertyChanged("Index"); }
        }

        public bool ShouldSerializeIndex()
        {
            return PropertiesChanged.Contains("Index");
        }
        
        //this xml is not valid for our datacontractserializer
        //[DataMember(Name = "limit", Order = 3)]
        //public int? Limit { get; set; }
    }
}
